package com.penjin.android.widget.calendar;

import android.content.Context;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.penjin.android.R;

import java.util.Random;

/**
 * Created by maotiancai on 2015/12/12.
 * 代表一个工作日的信息
 */
public class PenjinCalendarWorkItemNew extends RelativeLayout {

    private int day = 0;//日期
    private int[] banciColors = new int[]{R.color.pj_workday_color, R.color.pj_qingjia_color, R.color.pj_xiuxi_color};//班次对应的颜色

    private TextView work_item_text;
    private TextView work_item_day;
    private View work_item_wrapper;

    public DateEntity dateEntity;

    public PenjinCalendarWorkItemNew(Context context) {
        super(context);
        initView(context);
    }

    public PenjinCalendarWorkItemNew(Context context, AttributeSet attrs) {
        super(context, attrs);
        initView(context);
    }

    public PenjinCalendarWorkItemNew(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        initView(context);
    }

    public PenjinCalendarWorkItemNew(Context context, int banci, int day) {
        super(context);
        this.day = day;
        initView(context);
    }

    public PenjinCalendarWorkItemNew(Context context, int banci, DateEntity dateEntity) {
        super(context);
        this.dateEntity = dateEntity;
        initView(context);
    }

    private void initView(Context context) {
        LayoutInflater.from(context).inflate(R.layout.item_work_day_new, this);
        work_item_wrapper=findViewById(R.id.work_item_wrapper);
        work_item_text = (TextView) getRootView().findViewById(R.id.work_item_text);
        work_item_day = (TextView) findViewById(R.id.work_item_day);

        if (dateEntity.isSelfMonthDate) {//判断日期是否是当月的
            work_item_day.setText(dateEntity.day + "");
            work_item_text.setText(dateEntity.text);
        } else {
            work_item_day.setText(dateEntity.day + "");
            work_item_wrapper.setBackgroundColor(getResources().getColor(R.color.gray_8f));
        }
    }
}
